import React, { Component } from 'react'
import PubSub from 'pubsub-js'

export default class News extends Component {
    constructor(props) {
        super(props)
        this.state = {
            num: 123,
            ziText: '我是子组件'
        }
        this.show = this.show.bind(this)
        this.chuancan = this.chuancan.bind(this)
    }
    show() {
        console.log(123)
        console.log(this.props.fufun)
        this.props.fufun(this.state.ziText)
    }
    chuancan() {
        PubSub.publish('evt', this.state.ziText)
    }
    render() {
        return (
            <div>
                NEWS{this.props.text}
                <button onClick={() => this.show()}>点击</button>
                <button onClick={() => this.chuancan()}>点击我进行同级传参</button>
            </div>
        )
    }
}   
